﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;


namespace TestDxfDocument
{
    //2021-2-23 modify
    //未使用的方法添加进SocketServer.cs
    //未使用图层代码去除
    //参数字段错误修改
    //未使用参数注释掉
    class EndMillsForIndexableInserts
    {
        public static void SingleRowNonCentreCuttingEndMill(Dictionary<string, Object> data)//单排、非中心切削立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double phd = Convert.ToDouble(data["phd"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v7 = new Vector2(phd / 2, -oal + apmx);
                Vector2 v8 = new Vector2(dc / 2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v10 = new Vector2(v7.X, v9.Y);
                Vector2 v11 = new Vector2(v10.X, -oal + az);
                Vector2 v12 = new Vector2(v6.X, v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lcf - rcf);
                Vector2 v29 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v29.X, v28.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v24, v22), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v12.X, v11.Y)), -offset * 2 - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v15, v10), -offset, 0, dimensionStyle);
                dim10.UserText = "PHD = " + Math.Round(phd / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v9), offset * 2 + (v9.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v7 = new Vector2(phd / 2, -oal + apmx);
                Vector2 v8 = new Vector2(dc / 2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v10 = new Vector2(v7.X, v9.Y);
                Vector2 v11 = new Vector2(v10.X, -oal + az);
                Vector2 v12 = new Vector2(v6.X, v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lcf - rcf);
                Vector2 v29 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v3));
                Arc3.Vertexes.Add(new LwPolylineVertex(v4));
                Arc3.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                LwPolyline Arc20 = new LwPolyline();
                Arc20.Vertexes.Add(new LwPolylineVertex(v21));
                Arc20.Vertexes.Add(new LwPolylineVertex(v22));
                Arc20.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v29.X, v28.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v12.X, v11.Y)), -offset * 2 - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v15, v10), -offset, 0, dimensionStyle);
                dim10.UserText = "PHD = " + Math.Round(phd / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v9), offset * 2 + (v9.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SingleRowNonCentreCuttingVgrooveEndMill(Dictionary<string, Object> data)//单排、非中心V型主偏角立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double apmx = (dc2 - dc) / 2 * Math.Tan(kapr);
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v8 = new Vector2(dc2 / 2, -oal + apmx);
                Vector2 v7 = new Vector2(v8.X - az * Math.Tan(kapr), v8.Y + az);
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(v9.X - az * Math.Tan(kapr), -oal + az);
                Vector2 v11 = new Vector2(v6.X, (v8.X - v6.X) / Math.Tan(kapr) + v8.Y);
                Vector2 v12 = new Vector2(-v11.X + (v11.Y - v10.Y) / Math.Tan(kapr), v10.Y);
                Vector2 v13 = new Vector2(-v10.X, v10.Y);
                Vector2 v14 = new Vector2(-v9.X, v9.Y);
                Vector2 v15 = new Vector2(-v8.X, v8.Y);
                Vector2 v16 = new Vector2(-v11.X, v11.Y);
                Vector2 v17 = new Vector2(-v6.X, v6.Y);
                Vector2 v18 = new Vector2(-v5.X, v5.Y);
                Vector2 v19 = new Vector2(-v4.X, v4.Y);
                Vector2 v20 = new Vector2(-v3.X, v3.Y);
                Vector2 v21 = new Vector2(-v2.X, v2.Y);
                Vector2 v22 = new Vector2(-v1.X, v1.Y);
                Vector2 v23 = new Vector2(0, 2);
                Vector2 v24 = new Vector2(0, -oal - 2);
                Vector2 v25 = new Vector2(v6.X - rcf, v10.Y);
                Vector2 v26 = new Vector2(v25.X, -oal + lcf - rcf);
                Vector2 v27 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v11 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v10, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v16 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v19 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v23, v24 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v19, v20 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v20, v21 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v21, v22 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v22, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v21, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v20, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v19, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v18, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v17, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v25, v26 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v27));
                Arc30.Vertexes.Add(new LwPolylineVertex(v26));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v27.X, v26.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v14, v17), -offset * 2 - (v14.X + v17.X) / 2 + v15.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v14, v9), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v14, v15), -offset - (v14.X - v15.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v22, v20), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + v8.X - (v2.X + v9.X) / 2 + 0.25, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v21, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v19, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v16, v11), -offset * 2 - v11.Y + v9.Y, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v15, v8), -offset * 3 - v8.Y + v9.Y, 0, dimensionStyle);
                dim10.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v27, v9), offset * 2 + v8.X - (v9.X + v27.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v8 = new Vector2(dc2 / 2, -oal + apmx);
                Vector2 v7 = new Vector2(v8.X - az * Math.Tan(kapr), v8.Y + az);
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(v9.X - az * Math.Tan(kapr), -oal + az);
                Vector2 v11 = new Vector2(v6.X, (v8.X - v6.X) / Math.Tan(kapr) + v8.Y);
                Vector2 v12 = new Vector2(-v11.X + (v11.Y - v10.Y) / Math.Tan(kapr), v10.Y);
                Vector2 v13 = new Vector2(-v10.X, v10.Y);
                Vector2 v14 = new Vector2(-v9.X, v9.Y);
                Vector2 v15 = new Vector2(-v8.X, v8.Y);
                Vector2 v16 = new Vector2(-v11.X, v11.Y);
                Vector2 v17 = new Vector2(-v6.X, v6.Y);
                Vector2 v18 = new Vector2(-v5.X, v5.Y);
                Vector2 v19 = new Vector2(-v4.X, v4.Y);
                Vector2 v20 = new Vector2(-v3.X, v3.Y);
                Vector2 v21 = new Vector2(-v2.X, v2.Y);
                Vector2 v22 = new Vector2(-v1.X, v1.Y);
                Vector2 v23 = new Vector2(0, 2);
                Vector2 v24 = new Vector2(0, -oal - 2);
                Vector2 v25 = new Vector2(v6.X - rcf, v10.Y);
                Vector2 v26 = new Vector2(v25.X, -oal + lcf - rcf);
                Vector2 v27 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v3));
                Arc3.Vertexes.Add(new LwPolylineVertex(v4));
                Arc3.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v11 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v10, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v16 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v19 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v23, v24 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                LwPolyline Arc20 = new LwPolyline();
                Arc20.Vertexes.Add(new LwPolylineVertex(v19));
                Arc20.Vertexes.Add(new LwPolylineVertex(v20));
                Arc20.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc20, 0.3, contour);
                Vector2[] Line21 = { v20, v21 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v21, v22 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v22, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v21, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v20, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v19, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v18, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v17, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v25, v26 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v27));
                Arc30.Vertexes.Add(new LwPolylineVertex(v26));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v27.X, v26.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v14, v17), -offset * 2 - (v14.X + v17.X) / 2 + v15.X, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v14, v9), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v14, v15), -offset - (v14.X - v15.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + v8.X - (v2.X + v9.X) / 2 + 0.25, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v19, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v16, v11), -offset * 2 - v11.Y + v9.Y, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v15, v8), -offset * 3 - v8.Y + v9.Y, 0, dimensionStyle);
                dim10.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v27, v9), offset * 2 + v8.X - (v9.X + v27.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SingleRowNonCentreCuttingDovetailEndMill(Dictionary<string, Object> data)//单排、非中心切削燕尾槽铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double apmx = (dc - dc2) / 2 * Math.Tan(pi - kapr);
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            double lux = Convert.ToDouble(data["lux"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd / 2 - (lh - az) * Math.Tan(kapr - pi / 2) - dn / 2) * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2 - (lh - az) * Math.Tan(kapr - pi / 2), -oal + lh);
                Vector2 v7 = new Vector2(dc / 2 - w1 / Math.Sin(pi - kapr) - apmx / Math.Tan(pi - kapr), -oal + apmx);
                Vector2 v8 = new Vector2(dc2 / 2, v7.Y);
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(v9.X - w1 / Math.Sin(pi - kapr), v9.Y);
                Vector2 v11 = new Vector2(v10.X - az / Math.Tan(pi - kapr), -oal + az);
                Vector2 v12 = new Vector2(bd / 2 - (apmx - az) / Math.Tan(pi - kapr), v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v9.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lux);
                double a = Math.Tan(pi - kapr) * Math.Tan(pi - kapr) + 1;
                double b = 2 * v28.Y * Math.Tan(pi - kapr) - 2 * v9.X - 2 * (v6.Y + Math.Tan(pi - kapr) * v6.X) * Math.Tan(pi - kapr);
                double c = v9.X * v9.X + (v6.Y + Math.Tan(pi - kapr) * v6.X) * (v6.Y + Math.Tan(pi - kapr) * v6.X) + v28.Y * v28.Y - 2 * v28.Y * (v6.Y + Math.Tan(pi - kapr) * v6.X) - rcf * rcf;
                Vector2 v29 = new Vector2((-b - Math.Sqrt(b * b - 4 * a * c)) / 2 / a, -Math.Tan(pi - kapr) * (-b - Math.Sqrt(b * b - 4 * a * c)) / 2 / a + v6.Y + Math.Tan(pi - kapr) * v6.X);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                double ang = Math.Atan((v29.Y - v28.Y) / (v9.X - v29.X));
                double l = 2 * rcf * Math.Sin(ang / 2);
                double h = rcf - rcf * Math.Cos(ang / 2);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v9.X, v28.Y), rcf, (pi - ang) / pi * 180, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset - (v17.X - v16.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v24, v22), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(-v13.X, v11.Y)), -offset * 2 - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v17, v8), -offset - v8.Y + v9.Y, 0, dimensionStyle);
                dim10.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v28, v9), offset * 2 + (v9.X - v28.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LUX = " + Math.Round(lux / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, (pi - ang / 2) / pi * 180, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd / 2 - (lh - az) * Math.Tan(kapr - pi / 2) - dn / 2) * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2 - (lh - az) * Math.Tan(kapr - pi / 2), -oal + lh);
                Vector2 v7 = new Vector2(dc / 2 - w1 / Math.Sin(pi - kapr) - apmx / Math.Tan(pi - kapr), -oal + apmx);
                Vector2 v8 = new Vector2(dc2 / 2, v7.Y);
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(v9.X - w1 / Math.Sin(pi - kapr), v9.Y);
                Vector2 v11 = new Vector2(v10.X - az / Math.Tan(pi - kapr), -oal + az);
                Vector2 v12 = new Vector2(bd / 2 - (apmx - az) / Math.Tan(pi - kapr), v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v9.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lux);
                double a = Math.Tan(pi - kapr) * Math.Tan(pi - kapr) + 1;
                double b = 2 * v28.Y * Math.Tan(pi - kapr) - 2 * v9.X - 2 * (v6.Y + Math.Tan(pi - kapr) * v6.X) * Math.Tan(pi - kapr);
                double c = v9.X * v9.X + (v6.Y + Math.Tan(pi - kapr) * v6.X) * (v6.Y + Math.Tan(pi - kapr) * v6.X) + v28.Y * v28.Y - 2 * v28.Y * (v6.Y + Math.Tan(pi - kapr) * v6.X) - rcf * rcf;
                Vector2 v29 = new Vector2((-b - Math.Sqrt(b * b - 4 * a * c)) / 2 / a, -Math.Tan(pi - kapr) * (-b - Math.Sqrt(b * b - 4 * a * c)) / 2 / a + v6.Y + Math.Tan(pi - kapr) * v6.X);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                double ang = Math.Atan((v29.Y - v28.Y) / (v9.X - v29.X));
                double l = 2 * rcf * Math.Sin(ang / 2);
                double h = rcf - rcf * Math.Cos(ang / 2);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v9.X, v28.Y), rcf, (pi - ang) / pi * 180, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset - (v17.X - v16.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(-v13.X, v11.Y)), -offset * 2 - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v17, v8), -offset - v8.Y + v9.Y, 0, dimensionStyle);
                dim10.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
                angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v28, v9), offset * 2 + (v9.X - v28.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LUX = " + Math.Round(lux / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, (pi - ang / 2) / pi * 180, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void TSlotEndMill(Dictionary<string, Object> data)  //T型槽立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double ic = Convert.ToDouble(data["ic"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double phd = Convert.ToDouble(data["phd"]) * scale;
            if (ic == 0)
            {
                ic = (dc - phd) / 2;
            }
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, -oal + lh);
                Vector2 v5 = new Vector2(v4.X, -oal + apmx - az);
                Vector2 v6 = new Vector2(bd / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + ic);
                Vector2 v8 = new Vector2(dc / 2 - ic, v7.Y);
                Vector2 v9 = new Vector2(dc / 2, v8.Y);
                Vector2 v10 = new Vector2(v9.X, -oal);
                Vector2 v11 = new Vector2(v8.X, v10.Y);
                Vector2 v12 = new Vector2(v11.X, -oal + az);
                Vector2 v13 = new Vector2(-bd / 2, v12.Y);
                Vector2 v14 = new Vector2(-v6.X, v6.Y);
                Vector2 v15 = new Vector2(v14.X, -oal + apmx - ic);
                Vector2 v16 = new Vector2(-dc / 2, v15.Y);
                Vector2 v17 = new Vector2(v16.X, -oal + apmx);
                Vector2 v18 = new Vector2(v17.X + ic, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v14.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v12.Y);
                Vector2 v28 = new Vector2(v27.X, v6.Y);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v11, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v27, v28 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v21, v11), -offset * 2 + v17.X - (v21.X + v11.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v10), -offset * 2 - (v16.Y - v10.Y) / 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v11), -offset - (v11.X - v17.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v24, v22), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset + (v2.X - v10.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset + (v10.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v7.X, v12.Y)), -offset - az / 2, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + apmx - az);
                Vector2 v6 = new Vector2(bd / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + ic);
                Vector2 v8 = new Vector2(dc / 2 - ic, v7.Y);
                Vector2 v9 = new Vector2(dc / 2, v8.Y);
                Vector2 v10 = new Vector2(v9.X, -oal);
                Vector2 v11 = new Vector2(v8.X, v10.Y);
                Vector2 v12 = new Vector2(v11.X, -oal + az);
                Vector2 v13 = new Vector2(-bd / 2, v12.Y);
                Vector2 v14 = new Vector2(-v6.X, v6.Y);
                Vector2 v15 = new Vector2(v14.X, -oal + apmx - ic);
                Vector2 v16 = new Vector2(-dc / 2, v15.Y);
                Vector2 v17 = new Vector2(v16.X, -oal + apmx);
                Vector2 v18 = new Vector2(v17.X + ic, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v14.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v12.Y);
                Vector2 v28 = new Vector2(v27.X, v6.Y);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v11, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v27, v28 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v10), -offset * 2 - (v16.Y - v10.Y) / 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v11), -offset - (v11.X - v17.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 2 + (v2.X - v10.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 2 + (v10.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v7.X, v12.Y)), -offset - az / 2, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SingleRowRoundedEndMill(Dictionary<string, Object> data)//单排，圆刀片立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double dcx = dc + prfrad * 2;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2);
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v8 = new Vector2(dcx / 2 - prfrad, -oal + apmx);
                Vector2 v10 = new Vector2(v8.X, -oal + prfrad);
                Vector2 v7 = new Vector2(v6.X, v10.Y + Math.Sqrt(prfrad * prfrad - (v6.X - v8.X) * (v6.X - v8.X)));
                Vector2 v9 = new Vector2(v10.X - Math.Sqrt(prfrad * prfrad - (v10.Y - v8.Y + v6.X - v8.X) * (v10.Y - v8.Y + v6.X - v8.X)), v8.Y - v6.X + v8.X);
                Vector2 v11 = new Vector2(v6.X - rcf, v9.Y);
                Vector2 v12 = new Vector2(v11.X, -oal + lcf - rcf);
                Vector2 v13 = new Vector2(v6.X, -oal + lcf);
                Vector2 v14 = new Vector2(-v9.X, v9.Y);
                Vector2 v15 = new Vector2(-v8.X, v8.Y);
                Vector2 v16 = new Vector2(-v7.X, v7.Y);
                Vector2 v17 = new Vector2(-v10.X, v10.Y);
                Vector2 v18 = new Vector2(v15.X, v14.Y);
                Vector2 v19 = new Vector2(v16.X, v15.Y);
                Vector2 v20 = new Vector2(-v6.X, v6.Y);
                Vector2 v21 = new Vector2(-v5.X, v5.Y);
                Vector2 v22 = new Vector2(-v4.X, v4.Y);
                Vector2 v23 = new Vector2(-v3.X, v3.Y);
                Vector2 v24 = new Vector2(-v2.X, v2.Y);
                Vector2 v25 = new Vector2(-v1.X, v1.Y);
                Vector2 v26 = new Vector2(0, 2);
                Vector2 v27 = new Vector2(0, -oal - 2);
                Vector2 v28 = new Vector2((v14.X + v16.X) / 2, (v14.Y + v16.Y) / 2);
                double k = -(v16.X - v14.X) / (v16.Y - v14.Y);
                double b = v28.Y - k * v28.X;
                double x29 = (-2 * (k * b - v17.X - k * v17.Y) - Math.Sqrt(4 * (k * b - v17.X - k * v17.Y) * (k * b - v17.X - k * v17.Y) - 4 * (1 + k * k) * (v17.X * v17.X + v17.Y * v17.Y + b * b - prfrad * prfrad - 2 * b * v17.Y))) / 2 / (1 + k * k);
                Vector2 v29 = new Vector2(x29, k * x29 + b);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                fun.drawcircle(dxf, v10, prfrad, 0.3, contour);
                Vector2[] Line8 = { v9, v18 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v19));
                Arc9.Vertexes.Add(new LwPolylineVertex(v18));
                Arc9.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc9, 0.3, contour);
                Vector2[] Line10 = { v19, v20 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                double l = Math.Sqrt((v14.X - v16.X) * (v14.X - v16.X) + (v16.Y - v14.Y) * (v16.Y - v14.Y));
                double h = Math.Sqrt((v28.X - v29.X) * (v28.X - v29.X) + (v28.Y - v29.Y) * (v28.Y - v29.Y));
                LwPolyline Arc11 = new LwPolyline();
                Arc11.Vertexes.Add(new LwPolylineVertex(v16));
                Arc11.Vertexes.Add(new LwPolylineVertex(v14));
                Arc11.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc11, 0.3, contour);
                Vector2[] Line12 = { v20, v21 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v21, v22 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v22, v23 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v23, v24 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v24, v25 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v25, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v24, v2 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v26, v27 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v23, v3 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v4 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v21, v5 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v20, v6 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v11, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                LwPolyline Arc25 = new LwPolyline();
                Arc25.Vertexes.Add(new LwPolylineVertex(v13));
                Arc25.Vertexes.Add(new LwPolylineVertex(v12));
                Arc25.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc25, 0.3, contour);
                Arc arc26 = new Arc(v10, prfrad, -90, 0);
                Arc arc27 = new Arc(new Vector2(v13.X, v12.Y), rcf, 90, 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(new Vector2(v17.X, -oal), v20), -offset * 2 - (v17.X - v20.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v10), -offset - prfrad, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(new Vector2(v17.X, -oal), v15), -offset - prfrad, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v25, v23), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(v10.X, -oal), v1), offset * 2 + (v2.X - v10.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(v10.X, -oal), v1), offset * 2 + (v10.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v24, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(new Vector2(v20.X, v15.Y), new Vector2(v6.X, v8.Y)), -offset * 2 - apmx, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(new Vector2(-dcx / 2, v17.Y), new Vector2(dcx / 2, v10.Y)), -offset * 3 - prfrad, 0, dimensionStyle);
                dim10.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(arc27, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v13, new Vector2(v10.X, -oal)), offset + (v13.X - v10.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc26, 135, -prfrad * 2 - 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(pi / 4) / Math.Sin(pi / 4));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v8 = new Vector2(dcx / 2 - prfrad, -oal + apmx);
                Vector2 v10 = new Vector2(v8.X, -oal + prfrad);
                Vector2 v7 = new Vector2(v6.X, v10.Y + Math.Sqrt(prfrad * prfrad - (v6.X - v8.X) * (v6.X - v8.X)));
                Vector2 v9 = new Vector2(v10.X - Math.Sqrt(prfrad * prfrad - (v10.Y - v8.Y + v6.X - v8.X) * (v10.Y - v8.Y + v6.X - v8.X)), v8.Y - v6.X + v8.X);
                Vector2 v11 = new Vector2(v6.X - rcf, v9.Y);
                Vector2 v12 = new Vector2(v11.X, -oal + lcf - rcf);
                Vector2 v13 = new Vector2(v6.X, -oal + lcf);
                Vector2 v14 = new Vector2(-v9.X, v9.Y);
                Vector2 v15 = new Vector2(-v8.X, v8.Y);
                Vector2 v16 = new Vector2(-v7.X, v7.Y);
                Vector2 v17 = new Vector2(-v10.X, v10.Y);
                Vector2 v18 = new Vector2(v15.X, v14.Y);
                Vector2 v19 = new Vector2(v16.X, v15.Y);
                Vector2 v20 = new Vector2(-v6.X, v6.Y);
                Vector2 v21 = new Vector2(-v5.X, v5.Y);
                Vector2 v22 = new Vector2(-v4.X, v4.Y);
                Vector2 v23 = new Vector2(-v3.X, v3.Y);
                Vector2 v24 = new Vector2(-v2.X, v2.Y);
                Vector2 v25 = new Vector2(-v1.X, v1.Y);
                Vector2 v26 = new Vector2(0, 2);
                Vector2 v27 = new Vector2(0, -oal - 2);
                Vector2 v28 = new Vector2((v14.X + v16.X) / 2, (v14.Y + v16.Y) / 2);
                double k = -(v16.X - v14.X) / (v16.Y - v14.Y);
                double b = v28.Y - k * v28.X;
                double x29 = (-2 * (k * b - v17.X - k * v17.Y) - Math.Sqrt(4 * (k * b - v17.X - k * v17.Y) * (k * b - v17.X - k * v17.Y) - 4 * (1 + k * k) * (v17.X * v17.X + v17.Y * v17.Y + b * b - prfrad * prfrad - 2 * b * v17.Y))) / 2 / (1 + k * k);
                Vector2 v29 = new Vector2(x29, k * x29 + b);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                fun.drawcircle(dxf, v10, prfrad, 0.3, contour);
                Vector2[] Line8 = { v9, v18 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v19));
                Arc9.Vertexes.Add(new LwPolylineVertex(v18));
                Arc9.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc9, 0.3, contour);
                Vector2[] Line10 = { v19, v20 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                double l = Math.Sqrt((v14.X - v16.X) * (v14.X - v16.X) + (v16.Y - v14.Y) * (v16.Y - v14.Y));
                double h = Math.Sqrt((v28.X - v29.X) * (v28.X - v29.X) + (v28.Y - v29.Y) * (v28.Y - v29.Y));
                LwPolyline Arc11 = new LwPolyline();
                Arc11.Vertexes.Add(new LwPolylineVertex(v16));
                Arc11.Vertexes.Add(new LwPolylineVertex(v14));
                Arc11.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc11, 0.3, contour);
                Vector2[] Line12 = { v20, v21 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v21, v22 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v22, v23 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v23, v24 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v24, v25 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v25, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v24, v2 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v26, v27 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v23, v3 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v4 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v21, v5 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v20, v6 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v11, v12 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                LwPolyline Arc25 = new LwPolyline();
                Arc25.Vertexes.Add(new LwPolylineVertex(v13));
                Arc25.Vertexes.Add(new LwPolylineVertex(v12));
                Arc25.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc25, 0.3, contour);
                Arc arc26 = new Arc(v10, prfrad, -90, 0);
                Arc arc27 = new Arc(new Vector2(v13.X, v12.Y), rcf, 90, 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(new Vector2(v17.X, -oal), v20), -offset * 2 - (v17.X - v20.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v10), -offset - prfrad, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(new Vector2(v17.X, -oal), v15), -offset - prfrad, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(v10.X, -oal), v1), offset * 2 + (v2.X - v10.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(v10.X, -oal), v1), offset * 2 + (v10.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(new Vector2(v20.X, v15.Y), new Vector2(v6.X, v8.Y)), -offset * 2 - apmx, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(new Vector2(-dcx / 2, v17.Y), new Vector2(dcx / 2, v10.Y)), -offset * 3 - prfrad, 0, dimensionStyle);
                dim10.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(arc27, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v13, new Vector2(v10.X, -oal)), offset + (v13.X - v10.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc26, 135, -prfrad * 2 - 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void DieAndMouldEndMill(Dictionary<string, Object> data)//模具立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double apmx = prfrad;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2);
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v22 = new Vector2(0, -oal + apmx);
                Vector2 v7 = new Vector2(v6.X, v22.Y + Math.Sqrt(prfrad * prfrad - v6.X * v6.X));
                Vector2 v12 = new Vector2(v6.X - rcf, -oal + lcf - rcf);
                Vector2 v13 = new Vector2(v6.X, -oal + lcf);
                double x8 = v12.X;
                double y8 = v22.Y + Math.Sqrt(prfrad * prfrad - v12.X * v12.X);
                /*double a = rcf * rcf - prfrad * prfrad + v22.Y * v22.Y - v12.Y * v12.Y + v22.X * v22.X - v13.X * v13.X;
                double b = v22.Y - v12.Y;
                double c = v22.X - v13.X;
                if ((prfrad * prfrad) > ((v12.Y - v22.Y) * (v12.Y - v22.Y) + v12.X * v12.X))
                {
                    x8 = (2 * v13.X + a * c / b / b+v12.Y*(a-2*c)/b - Math.Sqrt((2 * v13.X + a * c / b / b + v12.Y * (a - 2 * c) / b) * (2 * v13.X + a * c / b / b + v12.Y * (a - 2 * c) / b) - 4 * (1 + c * c / b / b) * (v13.X * v13.X+v12.Y*v12.Y + a * a / 4 / b / b - rcf * rcf))) / 2 / (1 + c * c / b / b);
                    y8 = v12.Y + Math.Sqrt(rcf * rcf - (x8 - v13.X) * (x8 - v13.X));
                }*/
                Vector2 v8 = new Vector2(x8, y8);
                Vector2 v14 = new Vector2(-v6.X, v6.Y);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(v14.X, v22.Y);
                Vector2 v11 = new Vector2(v12.X, v22.Y - Math.Sqrt(v6.X * v6.X - v12.X * v12.X));
                Vector2 v15 = new Vector2(-v5.X, v5.Y);
                Vector2 v16 = new Vector2(-v4.X, v4.Y);
                Vector2 v17 = new Vector2(-v3.X, v3.Y);
                Vector2 v18 = new Vector2(-v2.X, v2.Y);
                Vector2 v19 = new Vector2(-v1.X, v1.Y);
                Vector2 v20 = new Vector2(0, 2);
                Vector2 v21 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                double l7 = Math.Sqrt((v8.X - v9.X) * (v8.X - v9.X) + (v8.Y - v9.Y) * (v8.Y - v9.Y));
                double h7 = prfrad + Math.Sqrt(prfrad * prfrad - l7 * l7 / 4);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v9));
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes[0].Bulge = h7 * 2 / l7;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line8 = { v10, v14 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                double l9 = Math.Sqrt((v11.X - v10.X) * (v11.X - v10.X) + (v10.Y - v11.Y) * (v10.Y - v11.Y));
                double h9 = v6.X - Math.Sqrt(v6.X * v6.X - l9 * l9 / 4);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v10));
                Arc9.Vertexes.Add(new LwPolylineVertex(v11));
                Arc9.Vertexes[0].Bulge = h9 * 2 / l9;
                fun.PolyFill(dxf, Arc9, 0.3, contour);
                Vector2[] Line10 = { v14, v15 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v17, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v19, v1 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v18, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v3 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v16, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v20, v21 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v15, v5 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v14, v6 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v11, v12 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                LwPolyline Arc23 = new LwPolyline();
                Arc23.Vertexes.Add(new LwPolylineVertex(v13));
                Arc23.Vertexes.Add(new LwPolylineVertex(v12));
                Arc23.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc23, 0.3, contour);
                Arc arc26 = new Arc(v22, prfrad, -90, 0);
                Arc arc27 = new Arc(new Vector2(v13.X, v12.Y), rcf, 90, 180);
                ///标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(new Vector2(0, -oal), v14), -offset * 2 - v6.X / 2 - dc / 2 + bd / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-dc / 2, v22.Y), new Vector2(dc / 2, v22.Y)), -offset * 2 - prfrad, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(new Vector2(0, -oal), v10), -offset - prfrad / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v19, v17), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(0, -oal), v1), offset * 2 + v2.X / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(0, -oal), v1), offset * 2 - v2.X / 2 + dc / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v18, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v16, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v10, new Vector2(v6.X, v22.Y)), -offset - apmx, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(arc27, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v13, new Vector2(0, -oal)), offset + v13.X / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc26, 45, -prfrad * 2 - 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(pi / 4) / Math.Sin(pi / 4));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v22 = new Vector2(0, -oal + apmx);
                Vector2 v7 = new Vector2(v6.X, v22.Y + Math.Sqrt(prfrad * prfrad - v6.X * v6.X));
                Vector2 v12 = new Vector2(v6.X - rcf, -oal + lcf - rcf);
                Vector2 v13 = new Vector2(v6.X, -oal + lcf);
                double x8 = v12.X;
                double y8 = v22.Y + Math.Sqrt(prfrad * prfrad - v12.X * v12.X);
                /*double a = rcf * rcf - prfrad * prfrad + v22.Y * v22.Y - v12.Y * v12.Y + v22.X * v22.X - v13.X * v13.X;
                double b = v22.Y - v12.Y;
                double c = v22.X - v13.X;
                if ((prfrad * prfrad) > ((v12.Y - v22.Y) * (v12.Y - v22.Y) + v12.X * v12.X))
                {
                    x8 = (2 * v13.X + a * c / b / b+v12.Y*(a-2*c)/b - Math.Sqrt((2 * v13.X + a * c / b / b + v12.Y * (a - 2 * c) / b) * (2 * v13.X + a * c / b / b + v12.Y * (a - 2 * c) / b) - 4 * (1 + c * c / b / b) * (v13.X * v13.X+v12.Y*v12.Y + a * a / 4 / b / b - rcf * rcf))) / 2 / (1 + c * c / b / b);
                    y8 = v12.Y + Math.Sqrt(rcf * rcf - (x8 - v13.X) * (x8 - v13.X));
                }*/
                Vector2 v8 = new Vector2(x8, y8);
                Vector2 v14 = new Vector2(-v6.X, v6.Y);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(v14.X, v22.Y);
                Vector2 v11 = new Vector2(v12.X, v22.Y - Math.Sqrt(v6.X * v6.X - v12.X * v12.X));
                Vector2 v15 = new Vector2(-v5.X, v5.Y);
                Vector2 v16 = new Vector2(-v4.X, v4.Y);
                Vector2 v17 = new Vector2(-v3.X, v3.Y);
                Vector2 v18 = new Vector2(-v2.X, v2.Y);
                Vector2 v19 = new Vector2(-v1.X, v1.Y);
                Vector2 v20 = new Vector2(0, 2);
                Vector2 v21 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                double l7 = Math.Sqrt((v8.X - v9.X) * (v8.X - v9.X) + (v8.Y - v9.Y) * (v8.Y - v9.Y));
                double h7 = prfrad + Math.Sqrt(prfrad * prfrad - l7 * l7 / 4);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v9));
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes[0].Bulge = h7 * 2 / l7;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line8 = { v10, v14 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                double l9 = Math.Sqrt((v11.X - v10.X) * (v11.X - v10.X) + (v10.Y - v11.Y) * (v10.Y - v11.Y));
                double h9 = v6.X - Math.Sqrt(v6.X * v6.X - l9 * l9 / 4);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v10));
                Arc9.Vertexes.Add(new LwPolylineVertex(v11));
                Arc9.Vertexes[0].Bulge = h9 * 2 / l9;
                fun.PolyFill(dxf, Arc9, 0.3, contour);
                Vector2[] Line10 = { v14, v15 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v17, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v19, v1 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v18, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v3 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v16, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v20, v21 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v15, v5 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v14, v6 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v11, v12 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                LwPolyline Arc23 = new LwPolyline();
                Arc23.Vertexes.Add(new LwPolylineVertex(v13));
                Arc23.Vertexes.Add(new LwPolylineVertex(v12));
                Arc23.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc23, 0.3, contour);
                Arc arc26 = new Arc(v22, prfrad, -90, 0);
                Arc arc27 = new Arc(new Vector2(v13.X, v12.Y), rcf, 90, 180);
                ///标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(new Vector2(0, -oal), v14), -offset * 2 - v6.X / 2 - dc / 2 + bd / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-dc / 2, v22.Y), new Vector2(dc / 2, v22.Y)), -offset * 2 - prfrad, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(new Vector2(0, -oal), v10), -offset - prfrad / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(0, -oal), v1), offset * 2 + v2.X / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(new Vector2(0, -oal), v1), offset * 2 - v2.X / 2 + dc / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v16, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v10, new Vector2(v6.X, v22.Y)), -offset - apmx, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(arc27, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v13, new Vector2(0, -oal)), offset + v13.X / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc26, 45, -prfrad * 2 - 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void FlattedProfileSlottingCutter(Dictionary<string, Object> data)  //槽、螺纹立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            if (w1 == 0)
            {
                w1 = rcf * 2 / 3;
            }
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v7 = new Vector2(dc / 2 - w1, -oal + apmx);
                Vector2 v8 = new Vector2(dc / 2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v10 = new Vector2(v7.X, v9.Y);
                Vector2 v11 = new Vector2(v10.X, -oal + az);
                Vector2 v12 = new Vector2(v6.X, v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lcf - rcf);
                Vector2 v29 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v29.X, v28.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v24, v22), -offset - 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 2 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 2 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v23, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v12.X, v11.Y)), -offset - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v9), offset + (v9.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lh + (bd - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(bd / 2, -oal + lh);
                Vector2 v7 = new Vector2(dc / 2 - w1, -oal + apmx);
                Vector2 v8 = new Vector2(dc / 2, v7.Y);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v10 = new Vector2(v7.X, v9.Y);
                Vector2 v11 = new Vector2(v10.X, -oal + az);
                Vector2 v12 = new Vector2(v6.X, v7.Y);
                Vector2 v13 = new Vector2(-bd / 2, v11.Y);
                Vector2 v14 = new Vector2(-v11.X, v11.Y);
                Vector2 v15 = new Vector2(-v10.X, v10.Y);
                Vector2 v16 = new Vector2(-v9.X, v9.Y);
                Vector2 v17 = new Vector2(-v8.X, v8.Y);
                Vector2 v18 = new Vector2(-v12.X, v12.Y);
                Vector2 v19 = new Vector2(-v6.X, v6.Y);
                Vector2 v20 = new Vector2(-v5.X, v5.Y);
                Vector2 v21 = new Vector2(-v4.X, v4.Y);
                Vector2 v22 = new Vector2(-v3.X, v3.Y);
                Vector2 v23 = new Vector2(-v2.X, v2.Y);
                Vector2 v24 = new Vector2(-v1.X, v1.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                Vector2 v27 = new Vector2(v6.X - rcf, v11.Y);
                Vector2 v28 = new Vector2(v27.X, -oal + lcf - rcf);
                Vector2 v29 = new Vector2(v6.X, -oal + lcf);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v3));
                Arc3.Vertexes.Add(new LwPolylineVertex(v4));
                Arc3.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v12 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v7 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v19 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v19, v20 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v25, v26 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                LwPolyline Arc20 = new LwPolyline();
                Arc20.Vertexes.Add(new LwPolylineVertex(v21));
                Arc20.Vertexes.Add(new LwPolylineVertex(v22));
                Arc20.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v24 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v24, v1 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v2 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v22, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v21, v4 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v20, v5 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v6 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v27, v28 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                LwPolyline Arc30 = new LwPolyline();
                Arc30.Vertexes.Add(new LwPolylineVertex(v29));
                Arc30.Vertexes.Add(new LwPolylineVertex(v28));
                Arc30.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc30, 0.3, contour);
                Arc arc31 = new Arc(new Vector2(v29.X, v28.Y), rcf, 90, 180);
                Line Line32 = new Line(v9, v8);
                Line Line33 = new Line(v9, new Vector2(v9.X + 5, v9.Y));
                Line32.Layer = dimensioning;
                Line33.Layer = dimensioning;
                dxf.AddEntity(Line32);
                dxf.AddEntity(Line33);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v16, v19), -offset * 2 - (v19.X - v16.X) / 2, 270, dimensionStyle);
                dim1.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v16, v9), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v16), -offset, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 2 + (v2.X - v9.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 2 + (v9.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v21, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, new Vector2(v12.X, v11.Y)), -offset - az, 0, dimensionStyle);
                dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v9), offset + (v9.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void EndMillNonCentreCuttingMultipleRows(Dictionary<string, Object> data)  //多排、非中心切削立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;

            double oal = Convert.ToDouble(data["oal"]);
            double scale; //放大系数
            if (oal <= 50)
            {
                scale = 5;
            }else if (50 < oal && oal <= 70)
            {
                scale = 4;
            }else if (70 < oal && oal <= 100)
            {
                scale = 3;
            }else if (100 < oal && oal <= 150)
            {
                scale = 2.5;
            }
            else
            {
                scale = 1.2;
            }

            oal = oal * scale;
            //double lpr = Convert.ToDouble(data["lpr"]);
            //double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            //double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
         
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = new Vector2(p0.X + dmm / 2 - 0.5, p0.Y);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X + dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 0.75);
            Vector2 p6 = new Vector2(p0.X + bd / 2, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p6.X, p0.Y - oal + (dc - bd) / 2);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);

            Vector2 ps = new Vector2(p0.X + dc / 3, p7.Y);
            Vector2 pe = new Vector2(p6.X, p0.Y - oal + 0.6 * dc);
            Vector2 ps1 = new Vector2(pe.X, pe.Y - dc / 6);
            Vector2 pe1 = new Vector2(pe.X, p0.Y - oal + dc / 3);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(ps));
            poly1.Vertexes.Add(new LwPolylineVertex(p7p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(pe));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            Vector2[] line1 = { ps1, pe1 };
            fun.drawBLine(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p2, p2p };
            fun.drawBLine(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p3, p3p };
            fun.drawBLine(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p4, p4p };
            fun.drawBLine(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p5, p5p };
            fun.drawBLine(dxf, line5, 0.2, contour);
            Vector2[] line6 = { p6, p6p };
            fun.drawBLine(dxf, line6, 0.2, contour);

            Vector2 p8 = new Vector2(p0.X + bd / 8, p7.Y);
            Vector2 p9 = new Vector2(p8.X, p8.Y + lh / 2.2);
            Vector2 p10 = new Vector2(p6.X, p0.Y - oal + 0.8 * lh);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 15);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);

            Vector2 p21 = new Vector2(p0.X + dc * 5.0 / 12, pe.Y);
            Vector2 p22 = new Vector2(p21.X, ps1.Y);
            Vector2 p23 = new Vector2(p21.X, pe1.Y);
            Vector2 p24 = new Vector2(p21.X, p0.Y - oal);
            Vector2 p25 = new Vector2(p6p.X - (dc - bd) / 4, p21.Y + dc * 2.0 / 15);
            Vector2 p26 = new Vector2(p25.X, p25.Y - dc / 6);
            Vector2 p27 = new Vector2(p25.X, p26.Y - dc / 10);
            Vector2 p28 = new Vector2(p25.X, p27.Y - dc / 6);
            Vector2 p29 = new Vector2(p25.X, p24.Y + dc / 6);
            Vector2 p30 = new Vector2(p25.X, p24.Y);
            Vector2 p31 = new Vector2(p0.X - dc / 2, p30.Y + (dc - bd) / 4);
            Vector2 p32 = new Vector2(p31.X + dc / 6, p31.Y);

            Vector2[] line7 = { p21, p22 };
            fun.drawBLine(dxf, line7, dc / 6, contour);
            Vector2[] line8 = { p23, p24 };
            fun.drawBLine(dxf, line8, dc / 6, contour);
            Vector2[] line9 = { p25, p26 };
            fun.drawBLine(dxf, line9, (dc - bd) / 2, contour);
            Vector2[] line10 = { p27, p28 };
            fun.drawBLine(dxf, line10, (dc - bd) / 2, contour);
            Vector2[] line11 = { p29, p30 };
            fun.drawBLine(dxf, line11, (dc - bd) / 2, contour);
            Vector2[] line12 = { p31, p32 };
            fun.drawBLine(dxf, line12, (dc - bd) / 2, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2 * 5 / scale;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5 * 5 / scale;
            double offset = 3.5 * 5 / scale;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm / scale);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls / scale);
            LinearDimension linedim3 = new LinearDimension(new Line(p6p, p30), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh / scale);
            LinearDimension linedim4 = new LinearDimension(new Line(p25, p30), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx / scale);
            LinearDimension linedim5 = new LinearDimension(new Line(p7, p7p), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, bd / scale);
            LinearDimension linedim6 = new LinearDimension(new Line(p31, new Vector2(p0.X - p31.X, p31.Y)), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, dc / scale);
            // LinearDimension linedim7 = new LinearDimension(new Line(p24, new Vector2(p6.X, p24.Y + lux)), offset, 270, dimensionStyle);
            // fun.dxflinedim(dxf, linedim7, lux);
            // LinearDimension linedim8 = new LinearDimension(new Line(p24, new Vector2(p2.X, p24.Y + lpr)), offset * 2, 270, dimensionStyle);
            // fun.dxflinedim(dxf, linedim8, lpr);
            LinearDimension linedim9 = new LinearDimension(new Line(p24, p1), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim9, oal / scale);
            
            double isframe = Convert.ToDouble(data["isframe"]);
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 370, p0.Y + 140), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void EndMillCentreCuttingMultipleRows(Dictionary<string, Object> data)  //多排、中心切削立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);


            double pi = Math.PI;

            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dn = Convert.ToDouble(data["dn"]);
            double bd = Convert.ToDouble(data["bd"]);
            double dc = Convert.ToDouble(data["dc"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["apmx"]);
            //double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            string path = Convert.ToString(data["path"]);
   
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = new Vector2(p0.X + dmm / 2 - 0.5, p0.Y);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X - dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 0.75);
            Vector2 p6 = new Vector2(p0.X + bd / 2, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p6.X, p0.Y - oal + (dc - bd) / 2);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);

            Vector2 p8 = new Vector2(p6.X, p7.Y + 0.8 * lh);
            Vector2 p9 = new Vector2(p0.X + 0.2 * bd, p7.Y + 0.4 * lh);
            Vector2 p10 = new Vector2(p0.X + 0.15 * bd, p7.Y);
            Vector2 p8p = new Vector2(p0.X - 0.3 * bd, p7.Y);
            Vector2 p9p = new Vector2(p8p.X, p0.Y - oal + dc / 3);
            Vector2 p10p = new Vector2(p6p.X, p9p.Y);

            Vector2 ps = new Vector2(p0.X + 0.3 * dc, p7.Y);
            Vector2 pe = new Vector2(p6.X, p0.Y - oal + dc * 13.0 / 30);
            Vector2 ps1 = new Vector2(pe.X, pe.Y - dc / 6);
            Vector2 pe1 = new Vector2(pe.X, p0.Y - oal + dc / 3);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(ps));
            poly1.Vertexes.Add(new LwPolylineVertex(p8p));
            poly1.Vertexes.Add(new LwPolylineVertex(p9p));
            poly1.Vertexes.Add(new LwPolylineVertex(p10p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(pe));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            Vector2[] line1 = { ps1, pe1 };
            fun.drawBLine(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p2, p2p };
            fun.drawBLine(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p3, p3p };
            fun.drawBLine(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p4, p4p };
            fun.drawBLine(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p5, p5p };
            fun.drawBLine(dxf, line5, 0.2, contour);
            Vector2[] line6 = { p6, p6p };
            fun.drawBLine(dxf, line6, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 15);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2 p21 = new Vector2(p0.X + dc * 5.0 / 12, pe.Y);
            Vector2 p22 = new Vector2(p21.X, ps1.Y);
            Vector2 p23 = new Vector2(p21.X, pe1.Y);
            Vector2 p24 = new Vector2(p21.X, p0.Y - oal);
            Vector2 p25 = new Vector2(p6p.X - (dc - bd) / 4, p21.Y + dc * 2.0 / 15);
            Vector2 p26 = new Vector2(p25.X, p25.Y - dc / 6);
            Vector2 p27 = new Vector2(p25.X, p22.Y + dc / 30.0);
            Vector2 p28 = new Vector2(p25.X, p9p.Y - (dc - bd) / 2);
            Vector2 p29 = new Vector2(p6p.X - (dc - bd) / 2, p9p.Y - (dc - bd) / 4);
            Vector2 p30 = new Vector2(p29.X + dc / 6, p29.Y);
            Vector2 p31 = new Vector2(p8p.X - (dc - bd) / 4, p0.Y - oal + dc / 6);
            Vector2 p32 = new Vector2(p31.X, p0.Y - oal);
            Vector2 p33 = new Vector2(p8p.X - (dc - bd) / 2, p7.Y - (dc - bd) / 4);
            Vector2 p34 = new Vector2(p33.X - dc / 3, p33.Y);

            Vector2[] line7 = { p21, p22 };
            fun.drawBLine(dxf, line7, dc / 6, contour);
            Vector2[] line8 = { p23, p24 };
            fun.drawBLine(dxf, line8, dc / 6, contour);
            Vector2[] line9 = { p25, p26 };
            fun.drawBLine(dxf, line9, (dc - bd) / 2, contour);
            Vector2[] line10 = { p27, p28 };
            fun.drawBLine(dxf, line10, (dc - bd) / 2, contour);
            Vector2[] line11 = { p29, p30 };
            fun.drawBLine(dxf, line11, (dc - bd) / 2, contour);
            Vector2[] line12 = { p31, p32 };
            fun.drawBLine(dxf, line12, (dc - bd) / 2, contour);
            Vector2[] line13 = { p33, p34 };
            fun.drawBLine(dxf, line13, (dc - bd) / 2, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p6p, p32), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim4 = new LinearDimension(new Line(p25, p32), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx);
            LinearDimension linedim5 = new LinearDimension(new Line(p29, new Vector2(p0.X + dc / 2, p7.Y)), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, dc);
            LinearDimension linedim6 = new LinearDimension(new Line(p10p, p7), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, bd);
            LinearDimension linedim7 = new LinearDimension(new Line(p24, new Vector2(p6.X, p0.Y - oal + lux)), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, lux);
            LinearDimension linedim8 = new LinearDimension(new Line(p24, new Vector2(p2.X, p0.Y - oal + lpr)), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim8, lpr);
            LinearDimension linedim9 = new LinearDimension(new Line(p24, p1), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim9, oal);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SpotFacingEndMill(Dictionary<string, Object> data)  //锪孔立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            
            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dn = Convert.ToDouble(data["dn"]);
            double bd = Convert.ToDouble(data["bd"]);
            double dc = Convert.ToDouble(data["dc"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["apmx"]);
            string path = Convert.ToString(data["path"]);
    
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, 0, dmm / 2 - 0.5);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X - dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 0.75);
            Vector2 p6 = new Vector2(p0.X + bd / 2, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p6.X, p0.Y - oal + (dc - bd) / 2);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);

            Vector2 ps = new Vector2(p0.X + dc / 2 - apmx, p7.Y);
            Vector2 pe = new Vector2(p6.X, p0.Y - oal + apmx);

            Vector2 p8 = new Vector2(p6.X, p7.Y + 0.8 * lh);
            Vector2 p9 = new Vector2(p0.X + 0.2 * bd, p7.Y + 0.4 * lh);
            Vector2 p10 = new Vector2(p0.X + 0.15 * bd, p7.Y);
            Vector2 p8p = new Vector2(p0.X - 0.35 * bd, p7.Y);
            Vector2 p9p = new Vector2(p8p.X, p0.Y - oal + dc * 0.35);
            Vector2 p10p = new Vector2(p6p.X, p9p.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(ps));
            poly1.Vertexes.Add(new LwPolylineVertex(p8p));
            poly1.Vertexes.Add(new LwPolylineVertex(p9p));
            poly1.Vertexes.Add(new LwPolylineVertex(p10p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(pe));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 15);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2[] line1 = { p2, p2p };
            fun.drawBLine(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p3, p3p };
            fun.drawBLine(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p4, p4p };
            fun.drawBLine(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p5, p5p };
            fun.drawBLine(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p6, p6p };
            fun.drawBLine(dxf, line5, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, pi / 2, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);

            Vector2 p21 = new Vector2(p0.X + (dc - apmx) / 2, p0.Y - oal + apmx);
            Vector2 p22 = new Vector2(p21.X, p0.Y - oal);
            Vector2 p23 = new Vector2(p9p.X - (dc - bd) / 4, p21.Y);
            Vector2 p24 = new Vector2(p23.X, p22.Y);
            Vector2 p25 = new Vector2(p9p.X - (dc - bd) / 2, p7p.Y - (dc - bd) / 4);
            Vector2 p26 = new Vector2(p25.X + apmx, p25.Y);

            Vector2[] line6 = { p21, p22 };
            fun.drawBLine(dxf, line6, apmx, contour);
            Vector2[] line7 = { p23, p24 };
            fun.drawBLine(dxf, line7, (dc - bd) / 2, contour);
            Vector2[] line8 = { p25, p26 };
            fun.drawBLine(dxf, line8, (dc - bd) / 2, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p6p, p7p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim4 = new LinearDimension(new Line(p23, p24), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx);
            LinearDimension linedim5 = new LinearDimension(new Line(p7, p7p), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, bd);
            LinearDimension linedim6 = new LinearDimension(new Line(new Vector2(p0.X - dc / 2, p24.Y), new Vector2(p0.X + dc / 2, p24.Y)), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, dc);
            LinearDimension linedim7 = new LinearDimension(new Line(p24, new Vector2(p6.X, p0.Y - oal + lux)), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, lux);
            LinearDimension linedim8 = new LinearDimension(new Line(p24, new Vector2(p2.X, p0.Y - oal + lpr)), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim8,lpr);
            LinearDimension linedim9 = new LinearDimension(new Line(p24, p1), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim9, oal);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void StraightBallNosedEndMill(Dictionary<string, Object> data)  //球头直立铣刀  刀片未画 未完成
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            double pi = Math.PI;

 
            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dn = Convert.ToDouble(data["dn"]);
            double bd = Convert.ToDouble(data["bd"]);
            double dc = Convert.ToDouble(data["dc"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["apmx"]);
            double prfrad = Convert.ToDouble(data["prfrad"]);
            string path = Convert.ToString(data["path"]);
       
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, 0, dmm / 2 - 0.5);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X + dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 1.25);
            Vector2 p6 = new Vector2(p0.X + bd / 2, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p6.X, p0.Y - oal + bd / 2);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);

            Arc arc1 = fun.DrawArc(new Vector2(p0.X, p0.Y - oal), new Vector2(p0.X, p7.Y), p7);
            Vector2 p8 = fun.getPointForArcandLine(new Vector2(p0.X + 0.1 * bd, p7.Y), new Vector2(p0.X + 0.1 * bd, p7.Y - 100), new Vector2(p0.X, p7.Y), arc1);
            Vector2 p9 = new Vector2(p8.X, p0.Y - oal + 0.5 * lh);
            Vector2 p10 = new Vector2(p6.X, p0.Y - oal + 0.85 * lh);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes[6].Bulge = Math.Tan(pi / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p7p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 15);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2[] line1 = { p2, p2p };
            fun.drawBLine(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p3, p3p };
            fun.drawBLine(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p4, p4p };
            fun.drawBLine(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p5, p5p };
            fun.drawBLine(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p6, p6p };
            fun.drawBLine(dxf, line5, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p6p, new Vector2(p0.X, p0.Y - oal)), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim4 = new LinearDimension(new Line(new Vector2(p6p.X, p0.Y - oal + apmx), new Vector2(p0.X, p0.Y - oal)), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx);
            LinearDimension linedim5 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), new Vector2(p6.X, p0.Y - oal + lux)), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, lux);
            LinearDimension linedim6 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), new Vector2(p2.X, p0.Y - oal + lpr)), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, lpr);
            LinearDimension linedim7 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), p1), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, oal);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void AngularBallNosedEndMill(Dictionary<string, Object> data)  //球头角度立铣刀  刀片未画 未完成
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            double pi = Math.PI;

            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double kapr = Convert.ToDouble(data["kapr"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dn = Convert.ToDouble(data["dn"]);
            double prfrad = Convert.ToDouble(data["prfrad"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["apmx"]);
            string path = Convert.ToString(data["path"]);
 
            double bd = 2 * (prfrad * Math.Sin(kapr) + (apmx - prfrad + prfrad * Math.Cos(kapr)) / Math.Tan(kapr));

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, 0, dmm / 2 + 0.5);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X + dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 1.25);
            Vector2 p6 = new Vector2(p0.X + 0.35 * bd, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p0.X + 0.5 * bd, p6.Y);
            Vector2 p8 = new Vector2(p7.X, p0.Y - oal + apmx);
            Vector2 p9 = new Vector2(p0.X + prfrad * Math.Sin(kapr), prfrad - prfrad * Math.Cos(kapr));
            Vector2 p9p = new Vector2(p0.X - p9.X, p9.Y);
            Vector2 p8p = new Vector2(p0.X - p8.X, p8.Y);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);

            Arc arc1 = fun.DrawArc(p9, new Vector2(p0.X, p0.Y - oal + prfrad), new Vector2(p0.X, p0.Y - oal));
            Vector2 p10 = new Vector2(p7.X, p0.Y - oal + 0.85 * lh);
            Vector2 p11 = new Vector2(p0.X + 0.1 * bd, p10.Y - 0.4 * bd);
            Vector2 p12 = fun.getPointForArcandLine(p11, fun.Polar(p11, 1.5 * pi, 100), new Vector2(p0.X, p0.Y - oal + prfrad), arc1);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes[8].Bulge = Math.Tan(kapr / 2);
            poly1.Vertexes.Add(new LwPolylineVertex(p9p));
            poly1.Vertexes.Add(new LwPolylineVertex(p8p));
            poly1.Vertexes.Add(new LwPolylineVertex(p7p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2[] line1 = { p2, p2p };
            fun.drawBLine(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p3, p3p };
            fun.drawBLine(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p4, p4p };
            fun.drawBLine(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p5, p5p };
            fun.drawBLine(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p6, p6p };
            fun.drawBLine(dxf, line5, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p1, p1p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p7p, new Vector2(p0.X, p0.Y - oal)), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim4 = new LinearDimension(new Line(p8p, new Vector2(p0.X, p0.Y - oal)), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx);
            LinearDimension linedim5 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), new Vector2(p8.X, p0.Y - oal + lux)), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, lux);
            LinearDimension linedim6 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), new Vector2(p2.X, p0.Y - oal + lpr)), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, lpr);
            LinearDimension linedim7 = new LinearDimension(new Line(new Vector2(p0.X, p0.Y - oal), p1), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, oal);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2000;
            dxf.Save(path);
        }

        public static void MultipleRowsNoncentrecuttingAngularEndMill(Dictionary<string, Object> data)  //多排、非中心切削角度立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;

            //double oal = 60.0; //Convert.ToDouble(data["oal"]);
            //double lpr = 45.0; //Convert.ToDouble(data["lpr"]);
            //double lux = 16.0; //Convert.ToDouble(data["lux"]);
            //double dmm = 12.0; //Convert.ToDouble(data["dmm"]);
            //double dn = 9.5; //Convert.ToDouble(data["dn"]);
            //double bd = 30.0; //Convert.ToDouble(data["bd"]);
            //double dc = 12.0; //Convert.ToDouble(data["dc"]);
            //double dcx = 25.0; //Convert.ToDouble(data["dcx"]);
            //double ls = 33.0; //Convert.ToDouble(data["ls"]);
            //double lh = 24.0; //Convert.ToDouble(data["lh"]);
            //double apmx = 15; //Convert.ToDouble(data["apmx"]);
            //double kapr = 70; //Convert.ToDouble(data["kapr"]);
            //string path = "E:\\dxfp\\ConvexProfileCutter.dxf"; // Convert.ToString(data["path"]);

            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dn = Convert.ToDouble(data["dn"]);
            double bd = Convert.ToDouble(data["bd"]);
            double dc = Convert.ToDouble(data["dc"]);
            double dcx = Convert.ToDouble(data["dcx"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["apmx"]);
            double kapr = Convert.ToDouble(data["kapr"]);
            string path = Convert.ToString(data["path"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p01 = new Vector2(p0.X, p0.Y - oal);
            Vector2 p1 = new Vector2(p0.X + dmm / 2 - 0.5, p0.Y);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 0.5);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls);
            Vector2 p4 = new Vector2(p0.X + dn / 2, p3.Y - 0.75);
            Vector2 p5 = new Vector2(p4.X, p0.Y - oal + lh + 0.75);
            Vector2 p6 = new Vector2(p0.X + dmm / 2, p0.Y - oal + lh);
            Vector2 p7 = new Vector2(p6.X, p01.Y + 0.07 * dc);
            Vector2 p7p = new Vector2(p0.X - p7.X, p7.Y);
            Vector2 p6p = new Vector2(p0.X - p6.X, p6.Y);
            Vector2 p5p = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p4p = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p3p = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p2p = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p1p = new Vector2(p0.X - p1.X, p1.Y);

            Vector2 p80 = new Vector2(p0.X - dc / 2, p01.Y);
            Vector2 p81 = new Vector2(p0.X - dc * 0.45, p7.Y);
            double c = Math.Atan((p6.Y - p81.Y) / (bd / 2 + p81.X));
            double d = fun.CalDistance(p80, p81);
            Vector2 p78 = fun.Polar(p81, pi - c, apmx / 5);
            Vector2 p77 = fun.Polar(p81, pi - c, apmx / 5 * 2);
            Vector2 p74 = fun.Polar(p81, pi - c, apmx / 5 * 3);
            Vector2 p73 = fun.Polar(p81, pi - c, apmx / 5 * 4);
            Vector2 p70 = fun.Polar(p81, pi - c, apmx / 5 * 5);
            Vector2 p79 = fun.Polar(p78, 1.5 * pi - c, d);
            Vector2 p76 = fun.Polar(p77, 1.5 * pi - c, d);
            Vector2 p75 = fun.Polar(p74, 1.5 * pi - c, d);
            Vector2 p72 = fun.Polar(p73, 1.5 * pi - c, d);
            Vector2 p71 = fun.Polar(p70, 1.5 * pi - c, d);
            Vector2 p92 = new Vector2(-p70.X, p70.Y);
            Vector2 p91 = new Vector2(-p71.X, p71.Y);
            Vector2 p90 = new Vector2(-p72.X, p72.Y);
            Vector2 p87 = new Vector2(-p75.X, p75.Y);
            Vector2 p86 = new Vector2(-p76.X, p76.Y);
            Vector2 p83 = new Vector2(-p80.X, p80.Y);
            Vector2 p84 = fun.Polar(p83, pi / 2 + c, dc * 0.35 - d);
            Vector2 p85 = fun.Polar(p86, pi / 2 + c, dc * 0.35 - d);
            Vector2 p88 = fun.Polar(p87, pi / 2 + c, dc * 0.35 - d);
            Vector2 p89 = fun.Polar(p90, pi / 2 + c, dc * 0.35 - d);

            Vector2 p69 = new Vector2(p0.X + bd / 2, p6.Y);

            Vector2 ps = new Vector2(p0.X + dc / 1, p7.Y);
            Vector2 pe = fun.Polar(p69, pi + c, bd * 20);
            Vector2 ps1 = new Vector2(pe.X, pe.Y - dc / 6);
            Vector2 pe1 = new Vector2(pe.X, p0.Y - oal + dc / 1);

            Vector2 pe2 = fun.Inters(p89, p90, p69, pe);
            Vector2 pe3 = fun.Inters(p88, p87, p69, pe);
            Vector2 pe4 = fun.Inters(p85, p86, p69, pe);
            Vector2 pe5 = fun.Inters(p84, p83, p81, ps);
            Vector2 p82 = new Vector2(-pe5.X, pe5.Y);
            Vector2 p68 = new Vector2(-p69.X, p69.Y);

            Solid s1 = new Solid(p70, p73, p71);
            dxf.AddEntity(s1);
            Solid s2 = new Solid(p71, p72, p73);
            dxf.AddEntity(s2);
            Solid s3 = new Solid(p74, p75, p76);
            dxf.AddEntity(s3);
            Solid s4 = new Solid(p74, p77, p76);
            dxf.AddEntity(s4);
            Solid s5 = new Solid(p78, p79, p80);
            dxf.AddEntity(s5);
            Solid s6 = new Solid(p78, p81, p80);
            dxf.AddEntity(s6);
            Solid s7 = new Solid(p82, p81, p80);
            dxf.AddEntity(s7);
            Solid s8 = new Solid(p83, p84, p85);
            dxf.AddEntity(s8);
            Solid s9 = new Solid(p86, p85, p83);
            dxf.AddEntity(s9);
            Solid s10 = new Solid(p87, p88, p89);
            dxf.AddEntity(s10);
            Solid s11 = new Solid(p87, p89, p90);
            dxf.AddEntity(s11);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(pe5));
            poly1.Vertexes.Add(new LwPolylineVertex(p81));
            poly1.Vertexes.Add(new LwPolylineVertex(p68));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p69));
            poly1.Vertexes.Add(new LwPolylineVertex(pe2));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            Vector2[] line1 = { ps1, pe1 };
            fun.drawPlineOfw(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p2, p2p };
            fun.drawPlineOfw(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p3, p3p };
            fun.drawPlineOfw(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p4, p4p };
            fun.drawPlineOfw(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p5, p5p };
            fun.drawPlineOfw(dxf, line5, 0.2, contour);
            Vector2[] line6 = { p6, p6p };
            fun.drawPlineOfw(dxf, line6, 0.2, contour);

            Vector2 p8 = new Vector2(p0.X + dc * 0.1, p7.Y);
            Vector2 p9 = fun.Polar(p8, c, lh / 2);
            Vector2 p10 = fun.Polar(p69, pi + c, 0.25 * lh);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 15);
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 1), fun.Polar(p0, 1.5 * pi, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);

            Vector2 p21 = new Vector2(p0.X + dc * 5.0 / 12, pe.Y);
            Vector2 p22 = new Vector2(p21.X, ps1.Y);
            Vector2 p23 = new Vector2(p21.X, pe1.Y);
            Vector2 p24 = new Vector2(p21.X, p0.Y - oal);
            Vector2 p25 = new Vector2(p6p.X - (dc - bd) / 4, p21.Y + dc * 2.0 / 15);
            Vector2 p26 = new Vector2(p25.X, p25.Y - dc / 6);
            Vector2 p27 = new Vector2(p25.X, p26.Y - dc / 10);
            Vector2 p28 = new Vector2(p25.X, p27.Y - dc / 6);
            Vector2 p29 = new Vector2(p25.X, p24.Y + dc / 6);
            Vector2 p30 = new Vector2(p25.X, p24.Y);
            Vector2 p31 = new Vector2(p0.X - dc / 2, p30.Y + (dc - bd) / 4);
            Vector2 p32 = new Vector2(p31.X + dc / 6, p31.Y);

            Vector2[] line7 = { p91, p92 };
            fun.drawPlineOfw(dxf, line7, 0.2, contour);
            Vector2[] line8 = { p90, p91 };
            fun.drawPlineOfw(dxf, line8, 0.2, contour);
            Vector2[] line9 = { p87, p86 };
            fun.drawPlineOfw(dxf, line9, 0.2, contour);
            Vector2[] line10 = { pe3, pe4 };
            fun.drawPlineOfw(dxf, line10, 0.2, contour);
            /*
            Vector2[] line11 = { p29, p30 };
            fun.drawPlineOfw(dxf, line11, 1 / 2, contour);
            Vector2[] line12 = { p31, p32 };
            fun.drawPlineOfw(dxf, line12, 1 / 2, contour);
            */
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim15 = new LinearDimension(new Line(p5, p5p), offset * 2, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim15, dn);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p3p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p68, p80), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim4 = new LinearDimension(new Line(p80, p71), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, apmx);
            LinearDimension linedim5 = new LinearDimension(new Line(p68, p69), offset * 6, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, bd);
            LinearDimension linedim6 = new LinearDimension(new Line(p80, p83), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, dc);
            LinearDimension linedim7 = new LinearDimension(new Line(p24, fun.Polar(pe5, c, lux / Math.Sin(c))), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, lux);
            LinearDimension linedim8 = new LinearDimension(new Line(p24, new Vector2(p2.X, p24.Y + lpr)), offset * 4, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim8, lpr);
            LinearDimension linedim9 = new LinearDimension(new Line(p24, p1), offset * 5, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim9, oal);
            LinearDimension linedim10 = new LinearDimension(new Line(p71, p91), offset * 4, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim10, dcx);
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(p83, p69), new Line(p83, fun.Polar(p83, 0, 70)), offset * 2, dimensionStyle);
            fun.dxfangdim(dxf, angdim1, kapr);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void DesignOfDetails(Dictionary<string, Object> data)  //钟罩式立铣刀 未完成
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层

            double pi = Math.PI;

            //double oal = 68.0; //Convert.ToDouble(data["oal"]);
            //double lpr = 60.0; //Convert.ToDouble(data["lpr"]);
            //double lux = 50.0; //Convert.ToDouble(data["lux"]);
            //double dmm = 15.0; //Convert.ToDouble(data["dmm"]);
            //double dc_2 = 6.0; //Convert.ToDouble(data["dc2"]);
            //double dc = 10.0; //Convert.ToDouble(data["dc"]);
            //double bd = 30.0; //Convert.ToDouble(data["bd"]);
            //double ls = 10.0; //Convert.ToDouble(data["ls"]);
            //double lh = 55.0; //Convert.ToDouble(data["lh"]);
            //double apmx = 40.0; //Convert.ToDouble(data["aomx"]);
            //string path = "E:\\dxfp\\DesignOfDetails.dxf"; // Convert.ToString(data["path"]);

            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double lux = Convert.ToDouble(data["lux"]);
            double dmm = Convert.ToDouble(data["dmm"]);
            double dc_2 = Convert.ToDouble(data["dc2"]);
            double dc = Convert.ToDouble(data["dc"]);
            double bd = Convert.ToDouble(data["bd"]);
            double ls = Convert.ToDouble(data["ls"]);
            double lh = Convert.ToDouble(data["lh"]);
            double apmx = Convert.ToDouble(data["aomx"]);
            string path = Convert.ToString(data["path"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p01 = new Vector2(p0.X, p0.Y - oal);
            Vector2 p1 = fun.Polar(p0, 0, dmm / 2 - 1);
            Vector2 p2 = new Vector2(p1.X + 0.5, p1.Y - 1);
            Vector2 p3 = new Vector2(p2.X, p0.Y - ls + 1);
            Vector2 p4 = new Vector2(p0.X + 0.45 * dmm, p3.Y);
            Vector2 p5 = new Vector2(p4.X, p0.Y - ls);
            Vector2 p6 = new Vector2(p0.X + 0.4 * bd, p5.Y);
            Vector2 p7 = new Vector2(p6.X, p01.Y + lh);
            Vector2 p8 = new Vector2(p0.X + 0.45 * bd, p7.Y);
            Vector2 p9 = new Vector2(p0.X + 0.5 * bd, p8.Y - 0.05 * bd);
            Vector2 p10 = new Vector2(p9.X, p01.Y + 0.1 * dc);
            Vector2 p11 = new Vector2(p01.X + 0.65 * dc, p10.Y);
            Vector2 p12 = new Vector2(p11.X, p11.Y + apmx * 0.5);
            Vector2 p13 = new Vector2(p01.X + 0.5 * dc, p12.Y);
            Vector2 p14 = new Vector2(p13.X, p01.Y + 1.3 * apmx);
            Vector2 p15 = new Vector2(p0.X + 0.35 * dmm, p7.Y);
            Vector2 p16 = new Vector2(p15.X, p5.Y);
            Vector2 p17 = new Vector2(p13.X, p01.Y + apmx * 0.9);
            Vector2 p18 = new Vector2(p9.X, p9.Y - 0.2 * lh);
            Vector2 p19 = new Vector2(-p10.X, p01.Y + 0.85 * apmx);
            Vector2 p20 = new Vector2(-p14.X, p19.Y);
            Vector2 p1p = new Vector2(-p1.X, p1.Y);
            Vector2 p2p = new Vector2(-p2.X, p2.Y);
            Vector2 p3p = new Vector2(-p3.X, p3.Y);
            Vector2 p4p = new Vector2(-p4.X, p4.Y);
            Vector2 p5p = new Vector2(-p5.X, p5.Y);
            Vector2 p6p = new Vector2(-p6.X, p6.Y);
            Vector2 p7p = new Vector2(-p7.X, p7.Y);
            Vector2 p8p = new Vector2(-p8.X, p8.Y);
            Vector2 p9p = new Vector2(-p9.X, p9.Y);
            Vector2 p10p = new Vector2(-p10.X, p10.Y);
            Vector2 p11p = new Vector2(-p11.X, p11.Y);
            Vector2 p14p = new Vector2(-p14.X, p14.Y);
            Vector2 p15p = new Vector2(-p15.X, p15.Y);
            Vector2 p16p = new Vector2(-p16.X, p16.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p13));
            poly1.Vertexes.Add(new LwPolylineVertex(p14));
            poly1.Vertexes.Add(new LwPolylineVertex(p14p));
            poly1.Vertexes.Add(new LwPolylineVertex(p20));
            poly1.Vertexes.Add(new LwPolylineVertex(p19));
            poly1.Vertexes.Add(new LwPolylineVertex(p9p));
            poly1.Vertexes.Add(new LwPolylineVertex(p8p));
            poly1.Vertexes.Add(new LwPolylineVertex(p7p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.2, contour);

            Vector2 p191 = new Vector2(p19.X, p19.Y - 0.2 * apmx);
            Vector2 p192 = new Vector2(p14p.X, p191.Y);
            Vector2 p193 = new Vector2(p01.X, p191.Y);
            Vector2 p111 = new Vector2(p01.X, p11.Y);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p111));
            poly2.Vertexes.Add(new LwPolylineVertex(p10p));
            poly2.Vertexes.Add(new LwPolylineVertex(p191));
            poly2.Vertexes[2].Bulge = Math.Tan(-6);
            poly2.Vertexes.Add(new LwPolylineVertex(p192));
            poly2.Vertexes[3].Bulge = Math.Tan(6);
            poly2.Vertexes.Add(new LwPolylineVertex(p193));
            fun.PolyFill(dxf, poly2, 0.2, contour);

            Vector2 p101 = new Vector2(p13.X + (bd - dc) / 8, p01.Y);
            Vector2[] line8 = { p101, fun.Polar(p101, 0.5 * pi, apmx * 0.25) };
            fun.drawPlineOfw(dxf, line8, (bd - dc) / 4, contour);
            Vector2 p201 = new Vector2(p01.X - dc_2 / 2 - (bd - dc) / 8, p01.Y + apmx);
            Vector2[] line9 = { p201, fun.Polar(p201, 1.5 * pi, apmx * 0.15) };
            fun.drawPlineOfw(dxf, line9, (bd - dc) / 4, contour);
            Vector2 p101p = new Vector2(-p101.X, p101.Y);
            Vector2 p101pp = new Vector2(p101p.X, p10.Y);
            Vector2[] line10 = { p101p, p101pp };
            fun.drawPlineOfw(dxf, line10, (bd - dc) / 4, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0.5 * pi, 3), fun.Polar(p0, 1.5 * pi, oal + 3) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);

            Vector2 p2022 = new Vector2(p20.X, p201.Y);
            Vector2 p202 = new Vector2(p201.X - (bd - dc) / 8, p201.Y);
            Vector2 p203 = new Vector2(p202.X, p19.Y);
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p18));
            poly3.Vertexes[0].Bulge = Math.Tan(16);
            poly3.Vertexes.Add(new LwPolylineVertex(p17));
            poly3.Vertexes.Add(new LwPolylineVertex(p14));
            poly3.Vertexes.Add(new LwPolylineVertex(p14p));
            poly3.Vertexes.Add(new LwPolylineVertex(p2022));
            poly3.Vertexes.Add(new LwPolylineVertex(p202));
            poly3.Vertexes.Add(new LwPolylineVertex(p203));
            poly3.Vertexes.Add(new LwPolylineVertex(p19));
            poly3.Vertexes.Add(new LwPolylineVertex(p9p));
            poly3.Vertexes.Add(new LwPolylineVertex(p8p));
            poly3.Vertexes.Add(new LwPolylineVertex(p8));
            poly3.Vertexes.Add(new LwPolylineVertex(p9));
            poly3.Vertexes.Add(new LwPolylineVertex(p18));
            fun.PolyFill(dxf, poly3, 0.2, contour);
            poly3.IsClosed = true;

            Vector2[] line1 = { p2, p2p };
            fun.drawPlineOfw(dxf, line1, 0.2, contour);
            Vector2[] line2 = { p15, p16p, p15p, p16, p15 };
            fun.drawPlineOfw(dxf, line2, 0.2, contour);
            Vector2[] line3 = { p4, p5 };
            fun.drawPlineOfw(dxf, line3, 0.2, contour);
            Vector2[] line4 = { p3, p3p };
            fun.drawPlineOfw(dxf, line4, 0.2, contour);
            Vector2[] line5 = { p4p, p5p };
            fun.drawPlineOfw(dxf, line5, 0.2, contour);
            Vector2[] line6 = { p6, p6p };
            fun.drawPlineOfw(dxf, line6, 0.2, contour);
            Vector2[] line7 = { p7, p7p };
            fun.drawPlineOfw(dxf, line7, 0.2, contour);

            String[] type = new String[100];
            Line[] line = new Line[100];
            Arc[] arc2 = new Arc[100];
            int numst = poly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < numst; i++)
            {
                type[i] = poly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (type[i] == "Line")
                {
                    line[i] = (Line)poly3.Explode()[i];
                }
                if (type[i] == "Arc")
                {
                    arc2[i] = (Arc)poly3.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, type, numst, 20, 15, line, arc2, hatching);
            //fun.hatchsubofline(dxf, type, numst, 5, 12, line, hatching);
            fun.PolyFill(dxf, poly3, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p2p), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, dmm);
            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p6p), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, ls);
            LinearDimension linedim3 = new LinearDimension(new Line(p8p, p101p), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lh);
            LinearDimension linedim9 = new LinearDimension(new Line(p201, p101p), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim9, apmx);
            LinearDimension linedim4 = new LinearDimension(new Line(p10, p10p), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, bd);
            LinearDimension linedim8 = new LinearDimension(new Line(new Vector2(p13.X, p01.Y), new Vector2(-p13.X, p01.Y)), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim8, dc);
            LinearDimension linedim10 = new LinearDimension(new Line(new Vector2(p01.X - dc_2 / 2, p01.Y + 0.85 * apmx), new Vector2(p13.X, p01.Y + 0.85 * apmx)), offset * 0, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim10, dc_2);
            LinearDimension linedim5 = new LinearDimension(new Line(new Vector2(p101.X, p01.Y + lux), p101), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, lux);
            LinearDimension linedim6 = new LinearDimension(new Line(p101, p6), offset * 3, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, lpr);
            LinearDimension linedim7 = new LinearDimension(new Line(p1, p101), offset * 4, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, oal);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2000;
            dxf.Save(path);
        }
    }
}
